package com.sq.universe.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.sq.universe.base.controller.BaseController;
import com.sq.universe.base.entity.RespEntity;
import com.sq.universe.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/sys")
@CrossOrigin
public class SystemController extends BaseController {

    @Autowired
    private SystemService systemService;

    /**
     * 获取服务IP
     * @param service
     * @return
     */
    @PostMapping("/getServiceIps/{service}")
    @ResponseBody
    public RespEntity getServiceIps(@PathVariable("service") String service){
        return new RespEntity("获取成功",systemService.getServiceIps(service));
    }

    /**
     * getServices
     * @param
     * @return
     */
    @PostMapping("/getServices")
    @ResponseBody
    public RespEntity getServices(){
        return new RespEntity("获取成功",systemService.getServices());
    }


    /**
     * getServices
     * @param
     * @return
     */
    @PostMapping("/getLogs")
    @ResponseBody
    public RespEntity getLogs(@RequestBody(required = false) Map map){
        return new RespEntity("获取成功",systemService.getLogs(JSONObject.parseObject(JSONObject.toJSONString(map))));
    }

}
